﻿using Habi.Solver.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;

namespace Habi.Solver.Models.Resources
{
    public class ResourceTaskModel : MetaModel
    {
        public string Url { get; set; }
        public int Type { get; set; }
        
        private string sizeText;
        public string SizeText
        {
            get
            {
                if (string.IsNullOrEmpty(sizeText))
                {
                    sizeText = NumberHelper.Byt2Unit(Size);
                }
                return sizeText;
            }
            set
            {
                sizeText = value;
            }
        }

        [DisplayFormat(DataFormatString = "{0:P0}")]
        public double Progress { get; set; }
        public string Icon { get; set; }

        public int Status { get; set; }

        public int UseTime { get; set; }

        public int ProcessId { get; set; }
    }

    public enum ResourceTaskStatus
    {
        Ready = 0,
        Uploading = 1,
        Uploaded = 2,
        Downloading = 3,
        Downloaded = 4,
        Canceled = 5,

        Transferring = 9,
        Successed = 10,

        Error = 6,
        NotFound = 7,
        Failed = 8
    }

    public enum TaskType
    {
        Download = 0,
        Upload = 1
    }
}
